<?php
	class khoidb
	{
		public function Add($TenKhoi)
		{
			$sql = "INSERT INTO `tbl_khoi`(`TenKhoi`) VALUES (".dataservice::slashes($TenKhoi).")";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaKhoi)
		{
			$sql = "DELETE FROM `tbl_khoi` WHERE MaKhoi = $MaKhoi";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaKhoi, $TenKhoi)
		{
			$sql = "UPDATE `tbl_khoi` SET TenKhoi = ".dataservice::slashes($TenKhoi)." WHERE MaKhoi = '$MaKhoi'"; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
		public function GetList($MaKhoi, $TenKhoi)
		{
			$sql = "SELECT * FROM `tbl_khoi` WHERE 1";
			if($MaKhoi!="")
				$sql .= " AND MaKhoi = $MaKhoi ";
			if($TenKhoi!="")
				$sql .= " AND TenKhoi LIKE '%$TenKhoi%' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		public function Find($TenKhoi)
		{
			$sql = "SELECT * FROM `tbl_khoi` WHERE 1";
			if($TenKhoi!="")
				$sql = " SELECT * FROM `tbl_khoi` WHERE TenKhoi LIKE '%$TenKhoi%' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>